package com.chen.controller;

import com.chen.base.utils.R;
import com.chen.service.ExamChooseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.io.IOException;

/**
 * 试卷试题答题
 */
@Controller
@RequestMapping("/examChoose")
public class ExamChooseController {

    // 记录答题数据
    @Autowired
    private ExamChooseService examChooseService;

    /**
     * 记录考生考试选择答案
     * @param studentId 考生编号
     * @param examPaperId 考试试卷编号
     * @param subjectId 当前选择试题编号
     * @param chooseAswer 选择答案
     * @throws IOException
     */
    @ResponseBody
    @RequestMapping(value="/choose", method= RequestMethod.POST)
    public R examChooseHandler(@RequestParam("studentId") Integer studentId, @RequestParam("examPaperId") Integer examPaperId,@RequestParam("subjectId") Integer subjectId, @RequestParam("chooseAswer") String chooseAswer) {
        // 记录回答
        examChooseService.recordAnswer(studentId, examPaperId, subjectId, chooseAswer);
        return R.ok().data("t");
    }

}
